package cn.scantd.scan;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;

import cn.scantd.kit.FileKit;
import cn.scantd.kit.StrKit;

public class ScanJava {

    private static final String FILE_TYPE = "java";
    
    private String scanPath;
    
    public ScanJava(String scanPath) {
        if (StrKit.isBlank(scanPath)) {
            throw new RuntimeException("The target path(scanPath) is empty!");
        }
        this.scanPath = scanPath;
    }
    
    public List<File> loadJavaFile() {
        List<File> files = new ArrayList<File>();
        FileKit.traceListFile(files, this.scanPath, new FileFilter() {
            
            @Override
            public boolean accept(File pathname) {
                if (FILE_TYPE.equals(FileKit.getExtension(pathname))) {
                    return true;
                }
                return false;
            }
        });
        
        return files;
    }
    
}
